package com.jun.dspool;

import javax.sql.DataSource;

import java.util.Properties;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;

import static java.util.concurrent.TimeUnit.MINUTES;
import static java.util.concurrent.TimeUnit.SECONDS;

public class JunConfig {
    // connection timeout, default 30 seconds
    private static final long CONNECTION_TIMEOUT = SECONDS.toMillis(30);
    // validation timeout, default 5 seconds
    private static final long VALIDATION_TIMEOUT = SECONDS.toMillis(5);
    // idle timeout, default 10 minutes
    private static final long IDLE_TIMEOUT = MINUTES.toMillis(10);
    // default pool size is 32
    private static final long DEFAULT_POOL_SIZE = 32;

    private volatile long connectionTimeout;
    private volatile long validationTimeout;
    private volatile long idleTimeout;
    private volatile int maxPoolSize;
    private volatile int minIdle;
    private volatile String username;
    private volatile String password;

    private String driverClassName;
    private String jdbcUrl;
    private String poolName;
    private Properties dataSourceProperties;
    private DataSource dataSource;
    private ThreadFactory threadFactory;
    private ScheduledExecutorService scheduledExecutor;
    private long keepaliveTime;
    private volatile boolean sealed;

    public JunConfig() {
        dataSourceProperties = new Properties();
        minIdle = -1;
        maxPoolSize = -1;
        connectionTimeout = CONNECTION_TIMEOUT;
        validationTimeout = VALIDATION_TIMEOUT;
        idleTimeout = IDLE_TIMEOUT;
    }

    public JunConfig(Properties properties) {

    }

}
